<template>
  <div>
    <div
      class="recommend"
      v-for="item in list"
      :key="item.id"
      @click="urlJump(item.id)"
    >
      <div class="recommendCont borderRigh">
        <img :src="item.imageHost + item.mainImage" alt="" />
        <p class="text">
          {{ item.name }}
        </p>
        <p class="price">
          ￥ <span>{{ item.price }}</span>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import { productRecommend } from "../api";
export default {
  data() {
    return {
      list: [],
    };
  },
  methods: {
    urlJump(id) {
      this.$router.push("/Details?id=" + id);
    },
  },
  created() {
    productRecommend((res) => {
      this.list = res.data;
    });
  },
};
</script>

<style lang="scss" scoped>
.recommend {
  float: left;
  width: 50%;
  height: 600px;
  box-sizing: border-box;
  .recommendCont {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    padding: 20px;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    font-size: 25px;
    img {
      width: 100%;
      height: 400px;
    }
    .text {
      overflow: hidden;
    }
  }
  .price {
    color: red;
    font-size: 30px;
  }
}
</style>